package com.yq.jedis;

import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.Set;

public class jedisdemo1 {
    public static void main(String[] args) {
        Jedis jedis=new Jedis("192.168.66.128",6379);
        String ping = jedis.ping();
        System.out.printf(ping);
    }
    @Test
    public void demo1selectallkey(){
        Jedis jedis=new Jedis("192.168.66.128",6379);
        Set<String> keys = jedis.keys("*");
        for (String key:keys){
            System.out.println(key);
        }
    }
    @Test
    /**
     * 添加一个数据
     */
    public void adddata(){
        Jedis jedis=new Jedis("192.168.66.128",6379);
//        //添加一个键值对
//        jedis.set("name","lucky");
//        //获取一个值通过键
//        String name=jedis.get("name");
        String codeKey = "VerifyCode13678765435:code";
        String name=jedis.get(codeKey);
        if(name==null){
            System.out.printf("asdf");
        }else {
            System.out.printf(name);
        }

    }
}
